package com.hzhjhh.init.dialog;

import javax.swing.*;

import lombok.Getter;
import lombok.Setter;

import java.awt.*;

/**
 * 结账弹出框
 * @author 12083
 *
 */
@Getter
@Setter
public class SettleDialog extends JDialog {
    JPanel panel1 = new JPanel();
    JTextField txfAmtTotal = new JTextField();
    JTextField txfActualRecAmt = new JTextField();
    JTextField txfGiveChangeAmt = new JTextField();
    JLabel lbAmtTotal = new JLabel();
    JLabel lbActualRecAmt = new JLabel();
    JLabel lbGiveChangeAmt = new JLabel();
    public SettleDialog(Frame owner, String title, boolean modal) {
        super(owner, title, modal);
        try {
            setDefaultCloseOperation(DISPOSE_ON_CLOSE);
            jbInit();
            pack();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    public SettleDialog() {
        this(new Frame(), "结算对话框", false);
    }
    /**
     * 结算对话框初始化
     * 
     * @param amtTotal 累计应收金额
     * @param actRecAmt 实收金额
     * @param giveChangeAmt 找零金额
     */
    public SettleDialog(String amtTotal, String actRecAmt, String giveChangeAmt) {
        this(new Frame(), "结算对话框", false);
        
        this.getTxfAmtTotal().setText(amtTotal);
        this.getTxfActualRecAmt().setText(actRecAmt);
        this.getTxfGiveChangeAmt().setText(giveChangeAmt);
        
        this.setSize(400, 300);
		this.setLocation(300, 250);
		this.setVisible(true);
    }

    private void jbInit() throws Exception {
        panel1.setLayout(null);
        txfAmtTotal = inputTxf(213, 44, 130, 42);
        txfActualRecAmt = inputTxf(213, 108, 130, 42);
        txfGiveChangeAmt = inputTxf(213, 171, 130, 42);
        lbAmtTotal = amtTotal();
        lbActualRecAmt = lbActualRecAmt();
        lbGiveChangeAmt = lbGiveChangeAmt();
        panel1.setBackground(Color.pink);
        getContentPane().add(panel1);
        panel1.add(lbAmtTotal);
        panel1.add(lbActualRecAmt);
        panel1.add(lbGiveChangeAmt);
        panel1.add(txfActualRecAmt);
        panel1.add(txfGiveChangeAmt);
        panel1.add(txfAmtTotal);
    }
    private JTextField inputTxf(int x, int y, int width, int height) {
		JTextField textField = new JTextField();
		textField.setFont(new Font("宋体", Font.PLAIN, 30));
        textField.setBounds(x, y, width, height);
		return textField;
	}
    private JLabel amtTotal() {
		JLabel amtTotal = new JLabel();
		amtTotal.setFont(new Font("宋体", Font.PLAIN, 30));
        amtTotal.setText("金额累计");
        amtTotal.setBounds(41, 45, 130, 42);
		return amtTotal;
	}
    private JLabel lbActualRecAmt() {
		JLabel actualRecAmt = new JLabel();
		actualRecAmt.setFont(new Font("宋体", Font.PLAIN, 30));
        actualRecAmt.setText("实收金额");
        actualRecAmt.setBounds(41, 108, 130, 42);
		return actualRecAmt;
	}
    private JLabel lbGiveChangeAmt() {
		JLabel giveChangeAmt = new JLabel();
		giveChangeAmt.setFont(new Font("宋体", Font.PLAIN, 30));
        giveChangeAmt.setText("找零金额");
        giveChangeAmt.setBounds(41, 171, 130, 42);
		return giveChangeAmt;
	}
}
